
const app = getApp();
var that;
var ipUrl=app.globalData.ipUrl;
Page({
  data:{
      courses:0,
      summoney:0,
      max:0,
      a:'收费明细',
      a1:'应缴学费',
      a2:'报名费',
      a3:'购买类型：',
      course:[]
  },
  onLoad(){
    that=this;
    var obj= that.data.course;
    var he =that.data.max;
    for(var i=0;i<=obj.length-1;i++){
      he+=obj[i].sum;
    }
    that.setData({
      max:he
    })
    wx.request({
      url: ipUrl+'/buycourse/buycourse/getBuyCourse?goukekey=gouke&sid=3',
      success (res) {
        var summ=0;
        for(var i=0;i<res.data.length;i++){
          summ+=res.data[i].xiangQing.ymoney
          console.log(res.data[i].xiangQing.ymoney)
        }
        
        console.log(res.data.length)
        console.log(summ)
        that.setData({
          course:res.data,
          courses:res.data.length,
          summoney:summ
        })
       }
    })
  },
    //赋值
    Change:function(e){
      //为对象的某一属性赋值
      this.setData({ max:222});
      console.log(e);
    },
  // 请求
    formSubmit:function(da){
      wx.request({
       url: ipUrl+'/buycourse/buycourse/getBuyCourse?goukekey=gouke&sid=3', //仅为示例，并非真实的接口地址
       data: da.detail.value,
       header: {
         'content-type': 'application/json'
       },
       success (res) {
        that.course=res.data;
          for(var i=0;i<res.data.length;i++){

          }
       }
     })
   console.log(da.detail.value)
   }
   //请求结束
  })
  